#include "stdafx.h"
#include <boost/test/auto_unit_test.hpp>
#include "bmock_control_tools_mock.hpp"
#include "function_mocks_newmocks.hpp"

extern  int test_mocks_x3;
struct arg_test3{};


BMOCK_TEST(arg_test3,test_create_mock_for_a_function)
{
	BMOCK_CREATE_MOCK(f3);
	BMOCK_EXPECT(f3());
	BMOCK_REPLAY;
	BOOST_CHECK_NO_THROW(f3());
	BMOCK_VERIFY;
}

BMOCK_TEST(arg_test3,test_create_mock_for_all_functions_starting_with)
{
	int a=3;
	int y=4;
	int z=8;
	int b=4;
	BMOCK_CREATE_MOCK(function_*);
	BMOCK_EXPECT(function_g3(y,z));
	BMOCK_EXPECT_RETURN(a,function_k3());
	BMOCK_REPLAY;
	BOOST_CHECK_NO_THROW(function_g3(y,z));
	BOOST_CHECK_NO_THROW(b=function_k3());
	BMOCK_VERIFY;
	BOOST_CHECK_EQUAL(a,b);
}



BMOCK_TEST(arg_test3,test_void_function_Not_Mock_without_arguments)
{
	test_mocks_x3=8;
	BOOST_CHECK_NO_THROW(f3());
	BOOST_CHECK_EQUAL(test_mocks_x3,0);
}
BMOCK_TEST(arg_test3,test_void_function_not_mock_with_IN_arguments)
{
	test_mocks_x3=8;
	int y=1;
	int z=0;
	BOOST_CHECK_NO_THROW(function_g3(y,z));
	BOOST_CHECK_EQUAL(test_mocks_x3,8);
	z=2;
	BOOST_CHECK_NO_THROW(function_g3(y,z));
	BOOST_CHECK_EQUAL(test_mocks_x3,0);
}
BMOCK_TEST(arg_test3,test_function_not_mock)
{
	int y=1;
	BOOST_CHECK_NO_THROW(y=function_k3());
	BOOST_CHECK_EQUAL(y,0);
}


BOOST_AUTO_TEST_CASE(test_coverage3)
{
	__BMOCK_CONTROL(c);
	const bmock::control_tools_ptr t(new bmock::control_tools_mock(c));
	const bmock::location          loc(__FILE__,__LINE__+7);
	__BMOCK_EXPECT_RETURN_C(c,true,t->check_ptr(1,1,"msg",loc));
	__BMOCK_EXPECT_RETURN_C(c,true,t->check_less_or_equal(1,1,"msg",loc));
	__BMOCK_EXPECT_C(c,t->require_equal(1,1,"msg",loc));
	__BMOCK_EXPECT_C(c,t->abort(loc));
	__BMOCK_EXPECT_RETURN_C(c,true,t->check_equal("exp","act","msg",loc));
	__BMOCK_REPLAY_C(c);
	const bmock::location          loc_1(__FILE__,__LINE__);
	BOOST_CHECK_NO_THROW(t->check_ptr(1,1,"msg",loc));
	BOOST_CHECK_NO_THROW(t->check_less_or_equal(1,1,"msg",loc));
	BOOST_CHECK_NO_THROW(t->require_equal(1,1,"msg",loc_1));
	BOOST_CHECK_NO_THROW(t->abort(loc_1));
	BOOST_CHECK_NO_THROW(t->check_equal("exp","act","msg",loc_1));
	__BMOCK_VERIFY_C(c);
}




